Lighttpd+FastCGI PHP5 Is Faster Than Apache2+mod_php5

Today I was benchmarking my upcoming PhpFaces code and was thoroughly impressed by the numbers returned by apachebench; until I started testing concurrency, that is. I tested a simple phpinfo() call with various levels of concurrency and was shocked to see that the problem may not be my code, but some bottleneck within either apache, php, or hardware. To test easy things (http server) first, I decided to benchmark using lighttpd, which I use on my local workstation. My perception of lighttpd+fastcgi has always been that since it's CGI it is slow--that's what they taught us, right? Well, FastCGI works differently than normal CGI, but wikipedia says it better than I can :).

To cut straight to the numbers:

Server

What?

# of Requests

Concurrency

Min Time

Max Time

Apache

phpinfo()

500

500

776

904

Lighttpd

-

-

-

377

429

Apache

PhpFaces

500

500

12517

40226

Lighttpd

-

-

-

1844

9957

Apache

PhpFaces (realistic)

150

25

1802

4060

Lighttpd

-

-

-

1595

2824


Complete apachebench output + server specs can be found here (self hosted, may not always be available).

I must say that I was taken completely by surprise by these results. While Lighttpd may not be the best for all sites, for the vast majority of sites that are either self-hosted or otherwise on dedicated installation of apache it is a shining winner. Lighttpd has all the basic functionality of apache including mod_rewrite, mod_alias, mod_redirect, mod_auth and mod_cgi/fastcgi. There are many others including mod_proxy, but I have yet to experiment with that. More information about Lighttpd can be found at their website, here.